package com.ruoyi.sea.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.sea.domain.SeaDataRange;
import com.ruoyi.sea.service.ISeaDataRangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 海洋数据区间范围值Controller
 *
 * @author ruoyi
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/sea/range")
public class SeaDataRangeController extends BaseController {
    @Autowired
    private ISeaDataRangeService seaDataRangeService;

    /**
     * 查询海洋数据区间范围值列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SeaDataRange seaDataRange) {
        startPage();
        List<SeaDataRange> list = seaDataRangeService.selectSeaDataRangeList(seaDataRange);
        return getDataTable(list);
    }

    /**
     * 获取海洋数据区间范围值详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(seaDataRangeService.selectSeaDataRangeById(id));
    }

    /**
     * 新增海洋数据区间范围值
     */
    @Log(title = "海洋数据区间范围值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SeaDataRange seaDataRange) {
        return toAjax(seaDataRangeService.insertSeaDataRange(seaDataRange));
    }

    /**
     * 修改海洋数据区间范围值
     */
    @Log(title = "海洋数据区间范围值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SeaDataRange seaDataRange) {
        return toAjax(seaDataRangeService.updateSeaDataRange(seaDataRange));
    }

    /**
     * 删除海洋数据区间范围值
     */
    @Log(title = "海洋数据区间范围值", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(seaDataRangeService.deleteSeaDataRangeByIds(ids));
    }
}
